<?php
/*
#####################################
#  ShopOS: Shopping Cart Software.
#  
    #  http://shopos3.com

#####################################
*/

  require('includes/top.php');


switch (@$_GET['action']) 
{
    case 'insert':
      $name = m::prepare_input($_POST['name']);
      $code = m::prepare_input($_POST['code']);
      $image = m::prepare_input($_POST['image']);
      $directory = m::prepare_input($_POST['directory']);
      $sort_order = m::prepare_input($_POST['sort_order']);
      $charset = m::prepare_input($_POST['charset']);


      db::query("insert into " . TABLE_LANGUAGES . " (name, code, image, directory, sort_order,language_charset) values ('" . db::input($name) . "', '" . db::input($code) . "', '" . db::input($image) . "', '" . db::input($directory) . "', '" . db::input($sort_order) . "', '" . db::input($charset) . "')");
      $insert_id = os_db_insert_id();


      $categories_query = db::query("select c.categories_id, cd.categories_name from " . TABLE_CATEGORIES . " c left join " . TABLE_CATEGORIES_DESCRIPTION . " cd on c.categories_id = cd.categories_id where cd.language_id = '" . $_SESSION['languages_id'] . "'");
      while ($categories = db::fetch_array($categories_query)) {
        db::query("insert into " . TABLE_CATEGORIES_DESCRIPTION . " (categories_id, language_id, categories_name) values ('" . $categories['categories_id'] . "', '" . $insert_id . "', '" . db::input($categories['categories_name']) . "')");
      }


      $products_query = db::query("select p.products_id, pd.products_name, pd.products_description, pd.products_url from " . TABLE_PRODUCTS . " p left join " . TABLE_PRODUCTS_DESCRIPTION . " pd on p.products_id = pd.products_id where pd.language_id = '" . $_SESSION['languages_id'] . "'");
      while ($products = db::fetch_array($products_query)) {
        db::query("insert into " . TABLE_PRODUCTS_DESCRIPTION . " (products_id, language_id, products_name, products_description, products_url) values ('" . $products['products_id'] . "', '" . $insert_id . "', '" . db::input($products['products_name']) . "', '" . db::input($products['products_description']) . "', '" . db::input($products['products_url']) . "')");
      }


      $products_options_query = db::query("select products_options_id, products_options_name from " . TABLE_PRODUCTS_OPTIONS . " where language_id = '" . $_SESSION['languages_id'] . "'");
      while ($products_options = db::fetch_array($products_options_query)) {
        db::query("insert into " . TABLE_PRODUCTS_OPTIONS . " (products_options_id, language_id, products_options_name) values ('" . $products_options['products_options_id'] . "', '" . $insert_id . "', '" . db::input($products_options['products_options_name']) . "')");
      }


      $products_options_values_query = db::query("select products_options_values_id, products_options_values_name from " . TABLE_PRODUCTS_OPTIONS_VALUES . " where language_id = '" . $_SESSION['languages_id'] . "'");
      while ($products_options_values = db::fetch_array($products_options_values_query)) {
        db::query("insert into " . TABLE_PRODUCTS_OPTIONS_VALUES . " (products_options_values_id, language_id, products_options_values_name) values ('" . $products_options_values['products_options_values_id'] . "', '" . $insert_id . "', '" . db::input($products_options_values['products_options_values_name']) . "')");
      }


      $manufacturers_query = db::query("select m.manufacturers_id, mi.manufacturers_url from " . TABLE_MANUFACTURERS . " m left join " . TABLE_MANUFACTURERS_INFO . " mi on m.manufacturers_id = mi.manufacturers_id where mi.languages_id = '" . $_SESSION['languages_id'] . "'");
      while ($manufacturers = db::fetch_array($manufacturers_query)) {
        db::query("insert into " . TABLE_MANUFACTURERS_INFO . " (manufacturers_id, languages_id, manufacturers_url) values ('" . $manufacturers['manufacturers_id'] . "', '" . $insert_id . "', '" . db::input($manufacturers['manufacturers_url']) . "')");
      }


      $orders_status_query = db::query("select orders_status_id, orders_status_name from " . TABLE_ORDERS_STATUS . " where language_id = '" . $_SESSION['languages_id'] . "'");
      while ($orders_status = db::fetch_array($orders_status_query)) {
        db::query("insert into " . TABLE_ORDERS_STATUS . " (orders_status_id, language_id, orders_status_name) values ('" . $orders_status['orders_status_id'] . "', '" . $insert_id . "', '" . db::input($orders_status['orders_status_name']) . "')");
      }
      
      $shipping_status_query = db::query("select shipping_status_id, shipping_status_name from " . TABLE_SHIPPING_STATUS . " where language_id = '" . $_SESSION['languages_id'] . "'");
      while ($shipping_status = db::fetch_array($shipping_status_query)) {
        db::query("insert into " . TABLE_SHIPPING_STATUS . " (shipping_status_id, language_id, shipping_status_name) values ('" . $shipping_status['shipping_status_id'] . "', '" . $insert_id . "', '" . db::input($shipping_status['shipping_status_name']) . "')");
      }
      
      $xsell_grp_query = db::query("select products_xsell_grp_name_id,xsell_sort_order, groupname from " . TABLE_PRODUCTS_XSELL_GROUPS . " where language_id = '" . $_SESSION['languages_id'] . "'");
      while ($xsell_grp = db::fetch_array($xsell_grp_query)) {
        db::query("insert into " . TABLE_PRODUCTS_XSELL_GROUPS . " (products_xsell_grp_name_id,xsell_sort_order, language_id, groupname) values ('" . $xsell_grp['products_xsell_grp_name_id'] . "','" . $xsell_grp['xsell_sort_order'] . "', '" . $insert_id . "', '" . db::input($xsell_grp['groupname']) . "')");
      }
      
            $customers_status_query=db::query("SELECT DISTINCT customers_status_id 
                                                FROM ".TABLE_CUSTOMERS_STATUS);
      while ($data=db::fetch_array($customers_status_query)) {
 
      $customers_status_data_query=db::query("SELECT * 
                                                FROM ".TABLE_CUSTOMERS_STATUS."
                                                WHERE customers_status_id='".$data['customers_status_id']."'"); 
      
      $group_data=db::fetch_array($customers_status_data_query);
        $c_data=array(
                'customers_status_id'=>$data['customers_status_id'],
                'language_id'=>$insert_id,
                'customers_status_name'=>$group_data['customers_status_name'],
                'customers_status_public'=>$group_data['customers_status_public'],
                'customers_status_image'=>$group_data['customers_status_image'],
                'customers_status_discount'=>$group_data['customers_status_discount'],
                'customers_status_ot_discount_flag'=>$group_data['customers_status_ot_discount_flag'],
                'customers_status_ot_discount'=>$group_data['customers_status_ot_discount'],
                'customers_status_graduated_prices'=>$group_data['customers_status_graduated_prices'],
                'customers_status_show_price'=>$group_data['customers_status_show_price'],
                'customers_status_show_price_tax'=>$group_data['customers_status_show_price_tax'],
                'customers_status_add_tax_ot'=>$group_data['customers_status_add_tax_ot'],
                'customers_status_payment_unallowed'=>$group_data['customers_status_payment_unallowed'],
                'customers_status_shipping_unallowed'=>$group_data['customers_status_shipping_unallowed'],
                'customers_status_discount_attributes'=>$group_data['customers_status_discount_attributes']);  
                
        db::perform(TABLE_CUSTOMERS_STATUS, $c_data);         
        
        }


      if ($_POST['default'] == 'on') {
        db::query("update " . TABLE_CONFIGURATION . " set configuration_value = '" . db::input($code) . "' where configuration_key = 'DEFAULT_LANGUAGE'");
        ///set_configuration_cache(); 
	  }

      set_default_cache();
      os_redirect(os_href_link(FILENAME_LANGUAGES, 'page=' . $_GET['page'] . '&lID=' . $insert_id));
      break;


    case 'save':
      $lID = m::prepare_input($_GET['lID']);
      $name = m::prepare_input($_POST['name']);
      $code = m::prepare_input($_POST['code']);
      $image = m::prepare_input($_POST['image']);
      $directory = m::prepare_input($_POST['directory']);
      $sort_order = m::prepare_input($_POST['sort_order']);
     $charset = m::prepare_input($_POST['charset']);
          
      db::query("update " . TABLE_LANGUAGES . " set name = '" . db::input($name) . "', code = '" . db::input($code) . "', image = '" . db::input($image) . "', directory = '" . db::input($directory) . "', sort_order = '" . db::input($sort_order) . "', language_charset = '" . db::input($charset) . "' where languages_id = '" . db::input($lID) . "'");


      if ($_POST['default'] == 'on') {
        db::query("update " . TABLE_CONFIGURATION . " set configuration_value = '" . db::input($code) . "' where configuration_key = 'DEFAULT_LANGUAGE'");
      /// set_configuration_cache(); 
	}

       set_default_cache();
      os_redirect(os_href_link(FILENAME_LANGUAGES, 'page=' . $_GET['page'] . '&lID=' . $_GET['lID']));
      break;


    case 'deleteconfirm':
      $lID = m::prepare_input($_GET['lID']);


      $lng_query = db::query("select languages_id from " . TABLE_LANGUAGES . " where code = '" . DEFAULT_CURRENCY . "'");
      $lng = db::fetch_array($lng_query);
      if ($lng['languages_id'] == $lID) {
        db::query("update " . TABLE_CONFIGURATION . " set configuration_value = '' where configuration_key = 'DEFAULT_CURRENCY'");
        ///set_configuration_cache(); 
	  }


      db::query("delete from " . TABLE_CATEGORIES_DESCRIPTION . " where language_id = '" . db::input($lID) . "'");
      db::query("delete from " . TABLE_PRODUCTS_DESCRIPTION . " where language_id = '" . db::input($lID) . "'");
      db::query("delete from " . TABLE_PRODUCTS_OPTIONS . " where language_id = '" . db::input($lID) . "'");
      db::query("delete from " . TABLE_PRODUCTS_OPTIONS_VALUES . " where language_id = '" . db::input($lID) . "'");
      db::query("delete from " . TABLE_MANUFACTURERS_INFO . " where languages_id = '" . db::input($lID) . "'");
      db::query("delete from " . TABLE_ORDERS_STATUS . " where language_id = '" . db::input($lID) . "'");
      db::query("delete from " . TABLE_LANGUAGES . " where languages_id = '" . db::input($lID) . "'");
      db::query("delete from " . TABLE_CONTENT_MANAGER . " where languages_id = '" . db::input($lID) . "'");
      db::query("delete from " . TABLE_PRODUCTS_CONTENT . " where languages_id = '" . db::input($lID) . "'");
      db::query("delete from " . TABLE_CUSTOMERS_STATUS . " where language_id = '" . db::input($lID) . "'");

      set_default_cache();
      os_redirect(os_href_link(FILENAME_LANGUAGES, 'page=' . $_GET['page']));
      break;
    case 'setflag':
          //Iaiiaeyai noaoon ycuea
          $flag = m::prepare_input($_GET['flag']);
          $aID = m::prepare_input($_GET['aID']);
      $cou = db::query("select count(status) from " . TABLE_LANGUAGES . " where status = '1'");
      $co = db::fetch_array($cou);     


      if ($co['count(status)'] !=1 || $flag != 0) //Anee aeoeaai iaei ycue - aai iaeucy ioee??eou
      {
               db::query("update " . TABLE_LANGUAGES . " set status = '" . db::input($flag) . "' where languages_id = '" . db::input($aID) . "'");
      }
	     set_default_cache();
        os_redirect(os_href_link(FILENAME_LANGUAGES, ''));
        break;
          
    case 'delete':
      $lID = m::prepare_input($_GET['lID']);


      $lng_query = db::query("select code from " . TABLE_LANGUAGES . " where languages_id = '" . db::input($lID) . "'");
      $lng = db::fetch_array($lng_query);


      $remove_language = true;
      if ($lng['code'] == DEFAULT_LANGUAGE) {
        $remove_language = false;
        $messageStack->add(ERROR_REMOVE_DEFAULT_LANGUAGE, 'error');
      }
	   set_default_cache();
      break;
  }
  
  add_action('head_admin', 'head_languages');
  
  function head_languages()
  {
     _e( '<script type="text/javascript" src="'.get_path('admin', 'http').'general.js"></script>');
  }
  
  $main->head();
?>
<body marginwidth="0" marginheight="0" topmargin="0" bottommargin="0" leftmargin="0" rightmargin="0" bgcolor="#FFFFFF">
<?php $main->top_menu(); ?>


<table border="0" width="100%" cellspacing="2" cellpadding="2">
  <tr>
    <td class="boxCenter" width="100%" valign="top">
    
    <?php os_header('flag_green.png',HEADING_TITLE); ?> 
    
    <table border="0" width="100%" cellspacing="0" cellpadding="2">
      <tr>
        <td><table border="0" width="100%" cellspacing="0" cellpadding="0">
          <tr>
            <td valign="top"><table border="0" width="100%" cellspacing="2" cellpadding="2">
              <tr class="dataTableHeadingRow" align="center">
                <td class="dataTableHeadingContent"><?php echo TABLE_HEADING_LANGUAGE_NAME; ?></td>
                <td class="dataTableHeadingContent"><?php echo TABLE_HEADING_LANGUAGE_CODE; ?></td>
                <td class="dataTableHeadingContent"><?php echo TABLE_HEADING_STATUS; ?></td>
                                 <td class="dataTableHeadingContent"><?php echo TABLE_HEADING_ACTION; ?> </td>
 
              </tr>
<?php
  $languages_query_raw = "select languages_id, name, code, image, directory, sort_order,status,language_charset from " . TABLE_LANGUAGES . " order by sort_order";
  $languages_split = new splitPageResults($_GET['page'], MAX_DISPLAY_ADMIN_PAGE, $languages_query_raw, $languages_query_numrows);
  $languages_query = db::query($languages_query_raw);
  while ($languages = db::fetch_array($languages_query)) {
    if (((!$_GET['lID']) || (@$_GET['lID'] == $languages['languages_id'])) && (!$lInfo) && (substr($_GET['action'], 0, 3) != 'new')) {
      $lInfo = new objectInfo($languages);
    }
   $color = $color == '#f9f9ff' ? '#f0f1ff':'#f9f9ff';
    if ( (is_object($lInfo)) && ($languages['languages_id'] == $lInfo->languages_id) ) {
      echo '                  <tr class="dataTableRowSelected" onmouseover="this.style.cursor=\'hand\'" onclick="document.location.href=\'' . os_href_link(FILENAME_LANGUAGES, 'page=' . $_GET['page'] . '&lID=' . $lInfo->languages_id . '&action=edit') . '\'">' . "\n";
    } else {
      echo '                  <tr onmouseover="this.style.background=\'#e9fff1\';this.style.cursor=\'hand\';" onmouseout="this.style.background=\''.$color.'\';" style="background-color:'.$color.'"  onclick="document.location.href=\'' . os_href_link(FILENAME_LANGUAGES, 'page=' . $_GET['page'] . '&lID=' . $languages['languages_id']) . '\'">' . "\n";
    }


    if (DEFAULT_LANGUAGE == $languages['code']) {
      echo '                <td class="dataTableContent"><b>' . $languages['name'] . ' (' . TEXT_DEFAULT . ')</b></td>' . "\n";
    } else {
      echo '                <td class="dataTableContent">' . $languages['name'] . '</td>' . "\n";
    }
?>
                <td class="dataTableContent" align="center"><?php echo $languages['code']; ?></td>
                <td class="dataTableContent" align="center"><?php
                                if ($languages['status'] == '1') {
        echo os_image(http_path('icons_admin')  . 'icon_status_green.gif', IMAGE_ICON_STATUS_GREEN, 10, 10) . '  <a href="' . os_href_link(FILENAME_LANGUAGES, 'action=setflag&flag=0&aID=' . $languages['languages_id']) . '">' . os_image(http_path('icons_admin') . 'icon_status_red_light.gif', IMAGE_ICON_STATUS_RED_LIGHT, 10, 10) . '</a>';
      } else {
        echo '<a href="' . os_href_link(FILENAME_LANGUAGES, 'action=setflag&flag=1&aID=' . $languages['languages_id']) . '">' . os_image(http_path('icons_admin') . 'icon_status_green_light.gif', IMAGE_ICON_STATUS_GREEN_LIGHT, 10, 10) . '</a>  ' . os_image(http_path('icons_admin') . 'icon_status_red.gif', IMAGE_ICON_STATUS_RED, 10, 10);
      }
?>       </td>
                                
                <td class="dataTableContent" align="center"><?php if ( (is_object($lInfo)) && ($languages['languages_id'] == $lInfo->languages_id) ) { echo os_image(http_path('icons_admin') . 'icon_arrow_right.gif'); } else { echo '<a href="' . os_href_link(FILENAME_LANGUAGES, 'page=' . $_GET['page'] . '&lID=' . $languages['languages_id']) . '">' . os_image(http_path('icons_admin') . 'icon_info.gif', IMAGE_ICON_INFO) . '</a>'; } ?> </td>
              </tr>
<?php
  }
?>
              <tr>
                <td colspan="3"><table border="0" width="100%" cellspacing="0" cellpadding="2">
                  <tr>
                    <td class="smallText" valign="top"><?php echo $languages_split->display_count($languages_query_numrows, MAX_DISPLAY_ADMIN_PAGE, $_GET['page'], TEXT_DISPLAY_NUMBER_OF_LANGUAGES); ?></td>
                    <td class="smallText" align="right"><?php echo $languages_split->display_links($languages_query_numrows, MAX_DISPLAY_ADMIN_PAGE, MAX_DISPLAY_PAGE_LINKS, $_GET['page']); ?></td>
                  </tr>
<?php
  if (!$_GET['action']) {
?>
                  <tr>
                    <td align="right" colspan="2"><?php echo '<a class="button" onClick="this.blur();" href="' . os_href_link(FILENAME_LANGUAGES, 'page=' . $_GET['page'] . '&lID=' . $lInfo->languages_id . '&action=new') . '"><span>' . BUTTON_NEW_LANGUAGE . '</span></a>'; ?></td>
                  </tr>
<?php
  }
?>
                </table></td>
              </tr>
            </table></td>
<?php
  $direction_options = array( array('id' => '', 'text' => TEXT_INFO_LANGUAGE_DIRECTION_DEFAULT),
                              array('id' => 'ltr', 'text' => TEXT_INFO_LANGUAGE_DIRECTION_LEFT_TO_RIGHT),
                              array('id' => 'rtl', 'text' => TEXT_INFO_LANGUAGE_DIRECTION_RIGHT_TO_LEFT));


  $heading = array();
  $contents = array();
  switch ($_GET['action']) {
    case 'new':
      $heading[] = array('text' => '<b>' . TEXT_INFO_HEADING_NEW_LANGUAGE . '</b>');


      $contents = array('form' => os_draw_form('languages', FILENAME_LANGUAGES, 'action=insert'));
      $contents[] = array('text' => TEXT_INFO_INSERT_INTRO);
      $contents[] = array('text' => '<br />' . TEXT_INFO_LANGUAGE_NAME . '<br />' . os_draw_input_field('name'));
      $contents[] = array('text' => '<br />' . TEXT_INFO_LANGUAGE_CODE . '<br />' . os_draw_input_field('code'));
      $contents[] = array('text' => '<br />' . TEXT_INFO_LANGUAGE_CHARSET . '<br />' . os_draw_input_field('charset'));
      $contents[] = array('text' => '<br />' . TEXT_INFO_LANGUAGE_IMAGE . '<br />' . os_draw_input_field('image', 'icon.gif'));
      $contents[] = array('text' => '<br />' . TEXT_INFO_LANGUAGE_DIRECTORY . '<br />' . os_draw_input_field('directory'));
      $contents[] = array('text' => '<br />' . TEXT_INFO_LANGUAGE_SORT_ORDER . '<br />' . os_draw_input_field('sort_order'));
      $contents[] = array('text' => '<br />' . os_draw_checkbox_field('default') . ' ' . TEXT_SET_DEFAULT);
      $contents[] = array('align' => 'center', 'text' => '<br /><input class="button" value="'.BUTTON_INSERT.'" type="submit" /><a class="button" onClick="this.blur();" href="' . os_href_link(FILENAME_LANGUAGES, 'page=' . $_GET['page'] . '&lID=' . $_GET['lID']) . '"><span>' . BUTTON_CANCEL . '</span></a>');
      break;


    case 'edit':
      $heading[] = array('text' => '<b>' . TEXT_INFO_HEADING_EDIT_LANGUAGE . '</b>');


      $contents = array('form' => os_draw_form('languages', FILENAME_LANGUAGES, 'page=' . $_GET['page'] . '&lID=' . $lInfo->languages_id . '&action=save'));
      $contents[] = array('text' => TEXT_INFO_EDIT_INTRO);
      $contents[] = array('text' => '<br />' . TEXT_INFO_LANGUAGE_NAME . '<br />' . os_draw_input_field('name', $lInfo->name));
      $contents[] = array('text' => '<br />' . TEXT_INFO_LANGUAGE_CODE . '<br />' . os_draw_input_field('code', $lInfo->code));
      $contents[] = array('text' => '<br />' . TEXT_INFO_LANGUAGE_CHARSET . '<br />' . os_draw_input_field('charset', $lInfo->language_charset));
      $contents[] = array('text' => '<br />' . TEXT_INFO_LANGUAGE_IMAGE . '<br />' . os_draw_input_field('image', $lInfo->image));
      $contents[] = array('text' => '<br />' . TEXT_INFO_LANGUAGE_DIRECTORY . '<br />' . os_draw_input_field('directory', $lInfo->directory));
      $contents[] = array('text' => '<br />' . TEXT_INFO_LANGUAGE_SORT_ORDER . '<br />' . os_draw_input_field('sort_order', $lInfo->sort_order));
      if (DEFAULT_LANGUAGE != $lInfo->code) $contents[] = array('text' => '<br />' . os_draw_checkbox_field('default') . ' ' . TEXT_SET_DEFAULT);
      $contents[] = array('align' => 'center', 'text' => '<br /><span class="button"><button type="submit" onClick="this.blur();" value="' . BUTTON_UPDATE . '"/>' . BUTTON_UPDATE . '</button></span> <a class="button" onClick="this.blur();" href="' . os_href_link(FILENAME_LANGUAGES, 'page=' . $_GET['page'] . '&lID=' . $lInfo->languages_id) . '"><span>' . BUTTON_CANCEL . '</span></a>');
      break;


    case 'delete':
      $heading[] = array('text' => '<b>' . TEXT_INFO_HEADING_DELETE_LANGUAGE . '</b>');


      $contents[] = array('text' => TEXT_INFO_DELETE_INTRO);
      $contents[] = array('text' => '<br /><b>' . $lInfo->name . '</b>');
      $contents[] = array('align' => 'center', 'text' => '<br />' . (($remove_language) ? '<a class="button" onClick="this.blur();" href="' . os_href_link(FILENAME_LANGUAGES, 'page=' . $_GET['page'] . '&lID=' . $lInfo->languages_id . '&action=deleteconfirm') . '"><span>' . BUTTON_DELETE . '</a></span>' : '') . ' <a class="button" onClick="this.blur();" href="' . os_href_link(FILENAME_LANGUAGES, 'page=' . $_GET['page'] . '&lID=' . $lInfo->languages_id) . '"><span>' . BUTTON_CANCEL . '</span></a>');
      break;


    default:
      if (is_object($lInfo)) {
        $heading[] = array('text' => '<b>' . $lInfo->name . '</b>');


        $contents[] = array('align' => 'center', 'text' => '<a class="button" onClick="this.blur();" href="' . os_href_link(FILENAME_LANGUAGES, 'page=' . $_GET['page'] . '&lID=' . $lInfo->languages_id . '&action=edit') . '"><span>' . BUTTON_EDIT . '</span></a><br /> <a class="button" onClick="this.blur();" href="' . os_href_link(FILENAME_LANGUAGES, 'page=' . $_GET['page'] . '&lID=' . $lInfo->languages_id . '&action=delete') . '"><span>' . BUTTON_DELETE . '</span></a>');
        $contents[] = array('text' => '<br /><b>' . TEXT_INFO_LANGUAGE_NAME . '</b> ' . $lInfo->name);
        $contents[] = array('text' => '<b>'.TEXT_INFO_LANGUAGE_CODE . '</b> ' . $lInfo->code);
        $contents[] = array('text' => '<b>'.TEXT_INFO_LANGUAGE_CHARSET_INFO . '</b> ' . $lInfo->language_charset);


        $contents[] = array('text' => '<br />' . os_image(http_path_admin('icons') .'lang/'. $lInfo->directory . '.gif'));
        $contents[] = array('text' => '<br />' . TEXT_INFO_LANGUAGE_DIRECTORY . '<br />/langs<br/></br><b>' . $lInfo->directory . '</b>');
        $contents[] = array('text' => '<br /><b>' . TEXT_INFO_LANGUAGE_SORT_ORDER . '</b> ' . $lInfo->sort_order);
      }
      break;
  }


  if ( (os_not_null($heading)) && (os_not_null($contents)) ) {
    echo '            <td class="right_box" valign="top">' . "\n";


    $box = new box;
    echo $box->infoBox($heading, $contents);


    echo '            </td>' . "\n";
  }
?>
          </tr>
        </table></td>
      </tr>
    </table></td>
  </tr>
</table>
<?php $main->bottom(); ?>